<template>
	<view class="u-page">
		<text style="flex-flow: row;justify-content: flex-start;display: flex;font-size: 15px;"><P/>根据联合重卡2023年年终考评工作安排，为落实干部群体的党风廉政建设和经营管理的双重责任，加强干部作风建设，特组织“一岗双责”品质测评。请各位对于被测评人给予公正、合理、客观的评价，每题需选择一个选项。选项分值如下：
		1、非常满意：5分
		2、满意：4分
		3、基本满意：3分
		4、不满意：2分
		5、非常不满意：1分
		特别说明：本次填写您的工号是为了测评页面能自动匹配您的上级，测试系统将严格保密您的信息。在此次测评中，您的反馈输出将会是完全匿名的(不显示工号)，且不会单独呈现；在测评报告中，您的反馈将和其他同事的反馈集中显示，您的测评结果也将会严格保密，请您放心填写。请您秉持认真严谨、客观公正、实事求是的态度完成本次评价，感谢您的支持。		
			
		</text>
		<u-divider text="" :dashed="true"></u-divider>
		<view v-show="false" style="flex-flow: row;justify-content: flex-start;display: flex;">
			<!-- <u-picker :show="dep_show" ref="depart" :columns="departs" @confirm="confirm_d" @cancel="cancelHand_d"></u-picker>
			<u-button @click="dep_show = true"><font color=red>*</font>点击选择被测评者:{{show_select}}</u-button>
			<u-picker :show="ren_show" ref="cp_name" :columns="cn_names" @confirm="confirm" @cancel="cancelHand" keyName="label"></u-picker>
		 --></view>
		<view >
					<font color=red>*</font><text class="u-demo-block__title">评价人员工号（必填）</text>
					 <u--input
					    placeholder="评价人员工号（必填）"
					    border="surround"
					    v-model="editFormFields.pjz_gh"
						
					  ></u--input>
					<u-divider text="" :dashed="true"></u-divider>
				</view>
		<view >
					<u-button @click="get_cpren" size="10px" style="padding-left: inherit;"><font color=red>*</font>点击选择被测评者:{{show_select}}</u-button>
					<u-picker :show="ren_show" ref="cp_name" :columns="cn_names" @confirm="confirm" @cancel="cancelHand" keyName="label"></u-picker>
				</view>
<u-divider text="" :dashed="true"></u-divider>
		<view v-for="item in editFormOptions" class="u-demo-block" >
			<view v-if="validate(item.field)">
				<text class="u-demo-block__title">{{item.title}}</text>
				<u-radio-group
				    v-model="editFormFields[item.field]"
				    placement="column"
				  >
				    <u-radio
				      :customStyle="{marginBottom: '8px'}"
				      label="非常满意"
				      name="5"
				    > </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="满意"
					  name="4"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="基本满意"
					  name="3"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="不满意"
					  name="2"
					> </u-radio>
					<u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="非常不满意"
					  name="1"
					> </u-radio>
					<!-- <u-radio
					  :customStyle="{marginBottom: '8px'}"
					  label="不予评价"
					  name="0"
					> </u-radio> -->
				  </u-radio-group>
				<u-divider text="" :dashed="true"></u-divider>
			</view>
		</view>
		<view class="btns">
			<view class="btn">
				<u-button type="success" @click="save" shape="circle" text="提交"></u-button>
			</view>
			
		</view>
		<u-divider text="" :dashed="true"></u-divider>
	</view>
</template>

<script>
	//************************************************
	//  *Author：jxx
	//  *QQ：283591387
	//  *自定义业务逻辑扩展
	//************************************************
    import options from './gbcp_wenjuOptions.js';
	let _options = options();
	export default {
		data() {
			return {
				all_pjz:[],
				show_select:"",
				dep_show:false,
				ren_show:false,
				departs:[],
				cn_names:[],
				all_ren:[],
				editFormFields:_options.editFormFields,
				editFormOptions:_options.editFormOptions,
			}
		},
		onShow() {
			this.$nextTick(()=>{
				
				for(var item in this.editFormFields){
					 if (item.substring(0,1)=='q'){
						//this.editFormFields[item]='5';
					}
				}
				 var turl = "/api/gbcp_wenju/get_data_all_cpren"
				        this.http.post(turl, {}, true).then((s) => {
						  this.departs.splice(0,this.departs.length);
				          this.departs.push(s.all_dep);
						  this.all_ren=s.all_ren;
						  this.all_pjz=s.pjz_ren;
						  console.log(s);
				        });
			})
		},
		onUnload(){
			console.log("onUnload..");
			uni.navigateTo({
				url: "/pages/mytable/gbcp_wenju/gbcp_wenju_custom"
			})
		},
		/* onBackPress(options) {//返回return 阻止按钮起效
			console.log("ddd");
			uni.switchTab({
					url: '/pages/tabBar/index/index'
				});
		    return true;//返回return 阻止按钮起效
		}, */
		methods: {
			get_cpren(){
				this.show_select="";
				if (this.editFormFields.pjz_gh==""){
					this.$toast("请先输入评价人员工号！");
				}
				let tt=this.all_pjz.filter(s=>{
					return s.pjz_gh==this.editFormFields.pjz_gh
				});
				if (tt.length<=0){
					this.$toast("请检查输入评价人员工号是否正确！");
					return;
				}
				let rens=new Array();;
				for (let i=0;i<tt.length;i++) {
					rens.push({
						label:tt[i].cp_name,
						xgh:tt[i].xgh,
						name:tt[i].cp_name,
					});
					this.editFormFields.pjz_name=tt[i].pjz_name
				}
				
				console.log(rens);
				this.cn_names.splice(0,this.cn_names.length);
				this.cn_names.push(rens);
				
				this.ren_show=true;
				
				/* var turl = "/api/Ls_pro_npqr_head/import_npqr?ls_pro_npqr_head_id=" + this.$store.getters.data().ls_pro_npqr_head_id+"&fujian="+fujian;
				      this.http.post(turl, {}, true).then((s) => {
				        if (s.status){
				          this.$message.success(s.message)
				        }else{
				          this.$message.error(s.message);
				        }
				      }); */
			},
			confirm_d(e) {
			                //console.log(e.value[0])
							//this.editFormFields.department=e.value[0]
							this.cn_names.splice(0,this.cn_names.length);
							let tt=this.all_ren.filter(s=>{
								return s.yjjg==e.value[0]
							});
							let rens=new Array();;
							for (let i=0;i<tt.length;i++) {
								
								rens.push({
									label:tt[i].name,
									xgh:tt[i].xgh,
									name:tt[i].name,
								});
							}
							this.cn_names.push(rens);
							//console.log(this.cn_names);
			                this.dep_show = false
							this.ren_show=true;
						},
			cancelHand_d(e){
				this.dep_show = false
			},
			confirm(e) {
			                //console.log(e.value)
							this.show_select=e.value[0].label
							this.editFormFields.cp_name=e.value[0].name
							this.editFormFields.cp_gh=e.value[0].xgh
							
			                this.ren_show = false
						},
			cancelHand(e){
				this.ren_show = false
			},
			viewClick() {
				//获取生成页面grid的对象
				console.log(this.$refs.grid.searchFormFields)
			},
			save(){
				
				let savedata={//判断前端对象属性为数组 
								mainData:this.editFormFields,
								delKeys: null,
								detailData: null
									}
				//this.savecheck();
				if (this.editFormFields.cp_name==""){
					this.$toast("请选择被测评人");
					return;
				}
				var keys=Object.keys(savedata.mainData);//需要把selectList字段类型转换为逗号分割的字符串
				      for (let index = 0; index < keys.length; index++) {
				        const e = keys[index];
						console.log(savedata.mainData[e]);
				        if(Array.isArray(savedata.mainData[e])){//判断savedata.mainData对象中哪些属性为数组的，如果是转为字符串
								console.log(savedata.mainData[e]+"array..........");
				            savedata.mainData[e]=savedata.mainData[e].join(',');//,转换为，分割的字符串，用于volform提交数据
				        }
				      }
				
				this.http.post("/api/gbcp_wenju/Add", savedata, true).then((s) => {
										if(s.status==false){
											this.$toast(s.message);
										}else{
											this.$toast("保存成功");
											uni.navigateTo({
												url: "/pages/mytable/gbcp_wenju/end_back"
											})
										}
										
										})
			},
			validate: function (value) {//判断字段是否为q开头
			
			                var h = value.substring(0,1);
							//console.log(h);
			                if(h == 'q'){
								//console.log(1);
			                    return true;
			                }
			                return false;
			            }
		
		}
	}
</script>

<style>
</style>
